/* GUI CONVERTED from reisrc01.p (converter v1.76) Sun Feb 24 21:19:04 2002 */
/* reisrc01.p - REPETITIVE FEEDBACK BACKFLUSH COMPONENT                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.10.1.7 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 6.0      LAST MODIFIED: 06/15/90   BY: emb                 */
/* REVISION: 6.0      LAST MODIFIED: 10/10/90   BY: SMM D085*           */
/* REVISION: 6.0      LAST MODIFIED: 12/17/90   BY: WUG *D227*          */
/* REVISION: 6.0      LAST MODIFIED: 01/11/91   BY: emb *D297*          */
/* REVISION: 6.0      LAST MODIFIED: 06/06/91   BY: RAM *D666*          */
/* REVISION: 6.0      LAST MODIFIED: 08/01/91   BY: emb *D805*          */
/* REVISION: 6.0      LAST MODIFIED: 09/20/91   BY: WUG *D858*          */
/* REVISION: 6.0      LAST MODIFIED: 10/03/91   BY: alb *D887*          */
/* REVISION: 6.0      LAST MODIFIED: 11/07/91   BY: WUG *D920*          */
/* REVISION: 6.0      LAST MODIFIED: 02/20/92   BY: emb *F234*          */
/* REVISION: 7.3      LAST MODIFIED: 09/27/93   BY: jcd *G247*          */
/* REVISION: 7.3      LAST MODIFIED: 11/10/92   BY: emb *G269*          */
/* REVISION: 7.3      LAST MODIFIED: 12/29/92   BY: pma *G382*          */
/* REVISION: 7.3      LAST MODIFIED: 11/09/92   BY: emb *G689*          */
/* REVISION: 7.3      LAST MODIFIED: 02/24/93   BY: emb *G760*          */
/* REVISION: 7.3      LAST MODIFIED: 09/12/94   BY: pxd *FR12*          */
/* REVISION: 7.3      LAST MODIFIED: 09/15/94   BY: slm *GM63*          */
/* REVISION: 7.3      LAST MODIFIED: 10/19/94   BY: pxd *FR91*          */
/* REVISION: 7.3      LAST MODIFIED: 10/21/94   BY: rmh *FR99*          */
/* REVISION: 7.3      LAST MODIFIED: 11/02/94   BY: pxd *FT38*          */
/* REVISION: 7.3      LAST MODIFIED: 11/06/94   BY: rwl *GO29*          */
/* REVISION: 7.3      LAST MODIFIED: 11/08/94   BY: ljm *GO33*          */
/* REVISION: 8.5      LAST MODIFIED: 11/28/94   BY: tmf *J040           */
/* REVISION: 8.5      LAST MODIFIED: 11/28/94   BY: taf *J038*          */
/* REVISION: 8.2      LAST MODIFIED: 12/16/94   BY: qzl *F09Z*          */
/* REVISION: 8.5      LAST MODIFIED: 04/18/95   BY: sxb *J04D*          */
/* REVISION: 8.5      LAST MODIFIED: 05/12/95   BY: pma *J04T*          */
/* REVISION: 8.5      LAST MODIFIED: 08/04/95   BY: tjs *J060*          */
/* REVISION: 7.2      LAST MODIFIED: 08/17/95   BY: qzl *F0TC*          */
/* REVISION: 7.3      LAST MODIFIED: 08/24/95   by: dzs *G0SY*          */
/* REVISION: 8.5      LAST MODIFIED: 09/26/95   BY: taf *J080*          */
/* REVISION: 8.5      LAST MODIFIED: 10/02/95   BY: tjs *J082*          */
/* REVISION: 8.5      LAST MODIFIED: 01/05/96   BY: kxn *J09L*          */
/* REVISION: 7.4      LAST MODIFIED: 12/12/95   BY: jym *G1G0*          */
/* REVISION: 8.5      LAST MODIFIED: 04/29/96   BY: gwm *J0KS*          */
/* REVISION: 8.5      LAST MODIFIED: 07/08/96   BY: *G1ZG* Julie Milligan     */
/* REVISION: 8.5      LAST MODIFIED: 09/03/96   BY: *G2D9* Julie Milligan     */
/* REVISION: 8.5      LAST MODIFIED: 12/26/96   BY: *H0Q8* Julie Milligan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *L07B* Jean Miller        */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Murali Ayyagari    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/08/00   BY: *N0GD* Ganga Subramanian  */
/* Old ECO marker removed, but no ECO header exists *D085*                    */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Old ECO marker removed, but no ECO header exists *J040*                    */
/* Revision: 1.10.1.6   BY: Rajesh Thomas    DATE: 07/23/01 ECO: *M1FL*       */
/* $Revision: 1.10.1.7 $  BY: Kirti Desai    DATE: 02/08/02 ECO: *M1TV*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reisrc01_p_1 "Substitute"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_2 "Qty Open"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_3 "Ref"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_4 "Cancel B/O"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_5 "Multi Entry"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_7 "Issue Picked"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_8 "Issue Alloc"
/* MaxLen: Comment: */

&SCOPED-DEFINE reisrc01_p_9 "Loc"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

{wndvar2.i "new shared"}

define shared variable ophist_recid as recid.
define shared variable eff_date like glt_effdate.
define shared variable wo_recno as recid.
define shared variable mod_issrc like mfc_logical.
define shared variable site like sr_site no-undo.

define new shared variable parent_assy like pts_par.
define new shared variable part like wod_part.
define new shared variable location like sr_loc no-undo.
define new shared variable lotserial like sr_lotser no-undo.
define new shared variable lotref like sr_ref format "x(8)" no-undo.
define new shared variable lotserial_qty like sr_qty no-undo.
define new shared variable multi_entry as logical
   label {&reisrc01_p_5} no-undo.
define new shared variable lotserial_control as character.
define new shared variable cline as character.
define new shared variable row_nbr as integer.
define new shared variable col_nbr as integer.
define new shared variable issue_or_receipt as character.
define new shared variable trans_um like pt_um.
define new shared variable trans_conv like sod_um_conv.
define new shared variable transtype as character initial "ISS-WO".
define new shared variable undo_tran like mfc_logical.

define new shared variable total_lotserial_qty like wod_qty_chg.
define new shared variable wo_recid as recid.
define new shared variable pk_recno as recid.
define new shared variable comp like ps_comp.
define new shared variable fill_all like mfc_logical
   label {&reisrc01_p_8} initial no.
define new shared variable fill_pick like mfc_logical
   label {&reisrc01_p_7} initial yes.

define variable op like wod_op.
define variable tmprnd as decimal initial 10000000000000000.
define variable nbr like wo_nbr.
define variable qopen like wod_qty_all label {&reisrc01_p_2}.
define variable yn like mfc_logical.
define variable ref like glt_ref.
define variable desc1 like pt_desc1.
define variable trqty like tr_qty_chg.
define variable trlot like tr_lot.
define variable qty_left like tr_qty_chg.
define variable del-yn like mfc_logical initial no.

define variable tot_lad_all like lad_qty_all.
define variable ladqtychg like lad_qty_all.
define variable wfirst as logical no-undo initial yes.
define variable sub_comp like mfc_logical label {&reisrc01_p_1}.
define variable firstpass like mfc_logical.
define variable cancel_bo like mfc_logical label {&reisrc01_p_4}.
define variable backflush_qty like wod_qty_chg.
define variable default_cancel like cancel_bo.
define variable ptum like pt_um no-undo.
define variable iss_loc like pk_loc.

define variable pkreference      like pk_reference no-undo.
define variable  wolot           like wo_lot_next.
define variable issue_component  like mfc_logical.
define variable wonbr            like wo_nbr.
define variable lotnext          like wo_lot_next.
define variable lotprcpt         like wo_lot_rcpt  no-undo.
define variable rejected         like mfc_logical.
define variable l_sr_site        like sr_site     no-undo.
define variable l_delete_sr_wkfl like mfc_logical no-undo.
define variable l_update_sr_wkfl like mfc_logical no-undo.
define variable l_sr_lineid      like sr_lineid    no-undo.

define buffer ptmstr for pt_mstr.

/* DEFINE VARIABLES FOR BILL OF MATERIAL EXPLOSION */
{gpxpld01.i "shared"}

/* TEMP-TABLE t_sr_wkfl STORES THE DEFAULT sr_wkfl RECORDS.    */
/* t_sr_wkfl RECORD IS DELETED WHEN THE DEFAULT sr_wkfl RECORD */
/* IS MODIFIED. DURING MULTI-ENTRY, IF t_sr_wkfl RECORD EXIST, */
/* DELETE DEFAULT sr_wkfl RECORD TO AVOID MANUAL DELETION.     */

define temp-table t_sr_wkfl no-undo
   field t_sr_lineid like sr_lineid
   index t_sr_lineid t_sr_lineid.

issue_or_receipt = getTermLabel("ISSUE",8).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part           colon 13
   op
   site           colon 58
   pt_desc1       colon 13
   location       colon 58 label {&reisrc01_p_9}
   pt_desc2       colon 13 no-label
   lotserial      colon 58
   lotserial_qty  colon 13 pt_um no-label
   lotref         colon 58
   sub_comp       colon 13
   multi_entry    colon 58
 SKIP(.4)  /*GUI*/
with overlay frame d side-labels width 80 attr-space row 15 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-d-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.
 RECT-FRAME-LABEL:HIDDEN in frame d = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame d =
  FRAME d:HEIGHT-PIXELS - RECT-FRAME:Y in frame d - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME d = FRAME d:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame d:handle).

FORM /*GUI*/ 
   pk_part
   sr_site
   sr_loc
   sr_lotser
   sr_ref format "x(8)" column-label {&reisrc01_p_3}
   sr_qty
with down frame e width 80 title color normal
   (getFrameTitle("ISSUE_DATA_REVIEW",25)) THREE-D /*GUI*/.


/* SET EXTERNAL LABELS */
setFrameLabels(frame e:handle).

/* INITIALISE TEMP-TABLE t_sr_wkfl */
for each t_sr_wkfl
   exclusive-lock:

   delete t_sr_wkfl.

end. /* FOR EACH t_sr_wkfl */

for first op_hist
   fields(op_part op_qty_comp op_qty_rjct op_wkctr)
   where recid(op_hist) = ophist_recid
   no-lock:
end. /* FOR FIRST op_hist */

for first wo_mstr
   fields(wo_lot wo_nbr wo_type wo_site)
   where recid(wo_mstr) = wo_recno
   no-lock:
end. /* FOR FIRST wo_mstr */

assign
   wonbr = wo_nbr
   wolot = wo_lot.

for first clc_ctrl
   fields(clc_comp_issue)
   no-lock:
end. /* FOR FIRST clc_ctrl */

if not available clc_ctrl
then do:
   {gprun.i ""gpclccrt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   for first clc_ctrl
      fields(clc_comp_issue)
      no-lock:
   end. /* FOR FIRST clc_ctrl */

end.

iss_loc = "".
if can-find (loc_mstr where loc_loc = op_wkctr and loc_site = wo_site)
   then iss_loc = op_wkctr.

do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


   for each sr_wkfl exclusive-lock where
      sr_userid = mfguser and
      sr_lineid begins "-":
         delete sr_wkfl.
   end.

   for each pk_det where
   pk_user = mfguser exclusive-lock:

      assign
         l_sr_lineid = "-" + string(pk_part,"x(18)") + pk_reference
         pk_qty      = ((pk_qty * (op_qty_comp + op_qty_rjct)) / bombatch).

      find sr_wkfl
         where sr_userid = mfguser
         and   sr_lineid = l_sr_lineid
         and   sr_site   = wo_site
         and   sr_loc    = pk_loc
      exclusive-lock no-error.

      for first ptmstr
         fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser pt_part pt_um)
         where ptmstr.pt_part = pk_part
         no-lock:
      end. /* FOR FIRST ptmstr */

      {gprun.i ""icedit2.p"" "(input ""ISS-WO"",
                                  input wo_site,
                                  input pk_loc,
                                  input ptmstr.pt_part,
                                  input """",
                                  input """",
                                  input pk_qty + if available sr_wkfl
                                                   then sr_qty else 0,
                                  input ptmstr.pt_um,
                                  input """",
                                  input """",
                                  output rejected)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if rejected
      and not mod_issrc then do on endkey undo, retry:
         /* UNABLE TO ISSUE OR RECEIVE FOR ITEM  */
         {pxmsg.i &MSGNUM=161 &ERRORLEVEL=2
                  &MSGARG1=ptmstr.pt_part}

      end.

      /* DEFAULT sr_wkfl RECORD IS STORED IN TEMP-TABLE t_sr_wkfl */
      if not available sr_wkfl
      then do:

         create sr_wkfl.
         create t_sr_wkfl.

         assign
            sr_userid   = mfguser
            sr_lineid   = l_sr_lineid
            sr_site     = wo_site
            sr_loc      = pk_loc
            sr_lotser   = ""
            sr_ref      = ""
            t_sr_lineid = l_sr_lineid.

         if recid(sr_wkfl) = -1 then .

      end. /* IF NOT AVAILABLE sr_wkfl */

      if available sr_wkfl
      then
         sr_qty = sr_qty + pk_qty.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

end.

seta:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   do transaction on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      setd:
      repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


         clear frame d.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.
         view frame d.

         /* DISPLAY DETAIL */
         select-part:
         repeat on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


            if batchrun = no
            then do:
               {gprun.i ""reisssw.p"" "(wfirst)"}
/*GUI*/ if global-beam-me-up then undo, leave.

               assign
                  wfirst   = no
                  pk_recno = window_recid.

            end. /* if batchrun = no */

            if keyfunction(lastkey) = "END-ERROR" then leave.

            clear frame d.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.

            do on error undo, retry with frame d:
               assign
                  part = ""
                  op   = 0.
               if pk_recno <> ?
               then do:

                  for first pk_det
                     fields(pk_loc pk_part pk_qty pk_reference pk_user)
                     where recid(pk_det) = pk_recno
                     no-lock:
                  end. /* FOR FIRST pk_det */

                  if available pk_det
                     then
                        assign
                           op   = integer(pk_reference)
                           part = pk_part.
               end.
               display
                  part
                  op.

               for first pt_mstr
                  fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser pt_part pt_um)
                  where pt_part = part
                  no-lock:
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

               if available pt_mstr then
               display
                  pt_desc1
                  pt_desc2.
               else
               display
                  "" @ pt_desc1
                  "" @ pt_desc2.

               input clear.

               get-part:
               do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


                  set
                     part
                     op
                  with frame d
                  editing:
                     if frame-field = "part"
                     then do:
                        /* FIND NEXT/PREVIOUS RECORD */
                        {mfnp01.i pk_det part pk_part
                           mfguser pk_user pk_det}

                        if recno <> ?
                        then do:
                           assign
                              part = pk_part
                              op   = integer(pk_reference).
                           display
                              part
                              op
                           with frame d.

                           for first pt_mstr
                              fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                                     pt_part pt_um)
                              where pt_part = part
                              no-lock:
                           end. /* FOR FIRST pt_mstr */

                           if available pt_mstr
                           then do:
                              display
                                 pt_um
                                 pt_desc1
                                 pt_desc2
                              with frame d.
                           end.
                        end.
                     end. /* if frame-field = part */
                     else do:
                        status input.
                        readkey.
                        apply lastkey.
                     end.
                  end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* set with editing */
                  status input.

                  assign
                     part
                     op.

                  if part = ""
                     then
                        leave.

                  firstpass = yes.

                  frame-d-loop:
                  repeat:

                     pause 0.
                     assign
                        sub_comp    = no
                        multi_entry = no.

                     find first pk_det where pk_user = mfguser
                        and pk_part      = part
                        and pk_reference = string(op)
                     exclusive-lock no-error.

                     if not available pk_det
                     then do:
                        pkreference = "".
                        for each pk_det
                           fields(pk_loc pk_part pk_qty pk_reference pk_user)
                           where pk_part = part
                           and   pk_user = mfguser no-lock:
                           if pkreference = "" then
                              pkreference = pk_reference.
                           if integer(pkreference) >
                              integer (pk_reference)
                              then
                              pkreference = pk_reference.
                        end. /* for each pk_det */

                        for first pk_det
                           fields(pk_loc pk_part pk_qty pk_reference pk_user)
                           where pk_part      = part
                           and   pk_user      = mfguser
                           and   pk_reference = pkreference
                           no-lock:
                        end. /* FOR FIRST pk_det */

                        if available pk_det
                        then do:
                           assign
                              part = pk_part
                              op   = integer(pk_reference).
                           display
                              part
                              op
                           with frame d.

                           for first pt_mstr
                              fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                                     pt_part pt_um)
                              where pt_part = part
                              no-lock:
                           end. /* FOR FIRST pt_mstr */

                           if available pt_mstr
                           then
                              display
                                 pt_um
                                 pt_desc1
                                 pt_desc2
                                 with frame d.
                        end. /* available pk_det */
                     end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* not availalbel pk_det */

                     if not available pk_det
                     then do:

                        /* UNRESTRICTED COMPONENT ISSUES */
                        if clc_comp_issue
                           or wo_type = "R"
                           or wo_type = "E"
                        then do:
                           /* ITEM DOES NOT EXIST ON THIS BILL OF MATERIAL */
                           {pxmsg.i &MSGNUM=547 &ERRORLEVEL=2}
                        end.
                        /* COMPLIANCE MODULE RESTRICTS COMP ISSUE */
                        else do:
                           /* ITEM DOES NOT EXIST ON THIS BILL OF MATERIAL */
                           {pxmsg.i &MSGNUM=547 &ERRORLEVEL=3}
                           undo select-part, retry.
                        end.

                        create pk_det.
                        assign
                           pk_reference = string(op)
                           pk_user      = mfguser
                           pk_part      = part.

                        if recid(pk_det) = -1 then .
                     end.

                     for first pt_mstr
                        fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                               pt_part pt_um)
                        where pt_part = part
                        no-lock:
                     end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

                     if not available pt_mstr
                     then do:

                        /* ITEM NUMBER DOES NOT EXIST */
                        {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
                        undo get-part, retry get-part.
                        display
                           part " " @ pt_um
                           " " @ pt_desc1
                           " " @ pt_desc2
                        with frame d.
                        ptum = "".
                     end.
                     else do:
                        if new pk_det
                        then
                           assign
                              pk_loc = pt_loc.
                        if iss_loc <> ""
                        then
                           pk_loc = iss_loc.
                        display
                           pt_part @ part
                           pt_um
                           pt_desc1
                           pt_desc2
                        with frame d.
                        ptum = pt_um.
                     end.
                     assign
                        trans_um   = if available pt_mstr then pt_um else ""
                        trans_conv = 1
                        qopen      = pk_qty
                        lotserial_control = "".

                     if available pt_mstr
                     then
                        lotserial_control = pt_lot_ser.
                     assign
                        location      = ""
                        lotserial     = ""
                        lotref        = ""
                        lotserial_qty = pk_qty
                        cline         = "-" + string(pk_part,"x(18)")
                                         + pk_reference
                        global_part   = pk_part.

                     for first sr_wkfl
                        fields(sr_lineid sr_loc sr_lotser sr_qty sr_ref
                               sr_site sr_userid)
                        where sr_userid = mfguser
                        and   sr_lineid = cline
                        no-lock:
                     end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST sr_wkfl */

                     if available sr_wkfl
                     then do:

                        for first sr_wkfl
                           fields(sr_lineid sr_loc sr_lotser sr_qty sr_ref
                                  sr_site sr_userid)
                           where sr_userid = mfguser
                           and   sr_lineid = cline
                           no-lock:
                        end. /* FOR FIRST sr_wkfl */

                        if available sr_wkfl
                        then
                           assign
                              site      = sr_site
                              location  = sr_loc
                              lotserial = sr_lotser
                              lotref    = sr_ref.
                        else
                           multi_entry  = yes.
                     end.
                     else
                        location = pk_loc.

                     do on error undo, retry
                     on endkey undo select-part, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


                        pk_recno = recid(pk_det).

                        update
                           lotserial_qty
                           sub_comp
                           site
                           location
                           lotserial
                           lotref
                           multi_entry
                        with frame d editing:
                           assign
                              global_site = input site
                              global_loc  = input location
                              global_lot  = input lotserial.
                           readkey.
                           apply lastkey.
                        end.

                        if sub_comp
                        then do:
                           if can-find (first pts_det where
                              pts_part = pk_part and pts_par = "")
                              or can-find (first pts_det where
                              pts_part = pk_part and pts_par = op_part)
                           then do:
                              {gprun.i ""resumt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

                              if keyfunction(lastkey) = "END-ERROR"
                                 then undo, retry.

                              for first pt_mstr
                                 fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                                        pt_part pt_um)
                                 where pt_part = part
                                 no-lock:
                              end. /* FOR FIRST pt_mstr */

                              if not available pt_mstr
                              then do:
                                 /* ITEM NUMBER DOES NOT EXIST */
                                 {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
                                 undo seta, retry seta.
                              end.

                              find pk_det where
                                 pk_user = mfguser and
                                 pk_part = part
                                 exclusive-lock no-error.
                              if not available pk_det
                              then do:
                                 create pk_det.
                                 assign
                                    pk_user      = mfguser
                                    pk_reference = string(op)
                                    pk_part      = part.
                                 if iss_loc <> ""
                                 then
                                    pk_loc = iss_loc.
                                 else
                                    pk_loc = pt_loc.

                                 if recid(pk_det) = -1 then .
                              end.
                              pk_qty = pk_qty + lotserial_qty.

                              find sr_wkfl where
                                 sr_userid = mfguser and
                                 sr_lineid = cline   and
                                 sr_site   = wo_site and
                                 sr_loc    = pk_loc  and
                                 sr_lotser = ""      and
                                 sr_ref    = ""
                                 exclusive-lock no-error.

                              if not available sr_wkfl
                              then do:
                                 create sr_wkfl.
                                 assign
                                    sr_userid = mfguser
                                    sr_lineid = cline
                                    sr_site   = wo_site
                                    sr_loc    = pk_loc.

                                 if recid(sr_wkfl) = -1 then .

                                 if not can-find(first t_sr_wkfl
                                    where t_sr_lineid = cline)
                                 then do:

                                    create t_sr_wkfl.
                                    t_sr_lineid = cline.

                                 end. /* IF NOT CAN-FIND(FIRST ... */

                              end.

                              sr_qty = sr_qty + lotserial_qty.

                              next frame-d-loop.
                           end.
                           else do with frame d:
                              /* APPROVED ALTERNATE ITEM DOESNT EXIST */
                              {pxmsg.i &MSGNUM=545 &ERRORLEVEL=3}
                              next-prompt sub_comp.
                              undo, retry.
                           end.
                        end.
/*GUI*/ if global-beam-me-up then undo, leave.


                        if can-find (first sr_wkfl
                           where sr_userid = mfguser
                           and sr_lineid = cline)
                           and not can-find (sr_wkfl
                           where sr_userid = mfguser
                           and sr_lineid = cline)
                           then multi_entry = yes.

                        total_lotserial_qty = pk_qty.

                        if multi_entry
                        then do:

                           assign
                              l_delete_sr_wkfl = no
                              l_update_sr_wkfl = no
                              /* LOTPRCPT FLAG INACTIVE ON ISSUES */
                              lotprcpt         = no
                              lotnext          = lotserial.

                           /* DEFAULT CREATED sr_wkfl RECORD IS     */
                           /* DELETED TO AVOID DELETING IT MANUALLY */
                           /* IN MULTI ENTRY SCREEN                 */

                           for first t_sr_wkfl
                              where t_sr_lineid = cline
                              no-lock:

                              find first sr_wkfl
                                 where sr_userid  = mfguser
                                 and   sr_lineid  = t_sr_lineid
                                 and   sr_loc     = pk_loc
                                 and   sr_ref     = ""
                                 and   sr_lot     = ""
                                 and   sr_qty     = pk_qty
                                 exclusive-lock no-error.

                              if available sr_wkfl
                              then do:

                                 /* STORING VALUE IN l_sr_site    */
                                 /* TO RE-CREATE DEFAULT sr_wkfl  */
                                 assign
                                    l_sr_site        = sr_site
                                    l_delete_sr_wkfl = yes.

                                 delete sr_wkfl.

                              end. /* IF AVAILABLE sr_wkfl */

                           end. /* FOR FIRST t_sr_wkfl */

                           {gprun.i ""icsrup1.p""
                              "(input        wo_site,
                                input        """",
                                input        """",
                                input-output lotnext,
                                input        lotprcpt,
                                input-output l_update_sr_wkfl)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                           /* RE-CREATE DEFAULT sr_wkfl, IF sr_wkfl */
                           /* IS NOT UPDATED IN MULTI ENTRY SCREEN. */
                           /* SO THIS RECORD IS DISPLAYED WHEN      */
                           /* "DISPLAY ITEMS BEING ISSUED" = YES    */
                           /* AND INVENTORY VALIDATION CAN BE DONE. */

                           if l_delete_sr_wkfl
                           then do:

                              if not l_update_sr_wkfl
                              then do:

                                 if not can-find(first sr_wkfl
                                        where sr_userid = mfguser
                                        and   sr_lineid = cline)
                                 then do:

                                    create sr_wkfl.

                                    assign
                                       sr_userid           = mfguser
                                       sr_lineid           = cline
                                       sr_site             = l_sr_site
                                       sr_loc              = pk_loc
                                       sr_lotser           = ""
                                       sr_ref              = ""
                                       sr_qty              = pk_qty
                                       total_lotserial_qty = pk_qty.

                                    if recid(sr_wkfl) = -1 then .

                                 end. /* IF NOT CAN-FIND(FIRST ... */

                              end. /* IF NOT l_update_sr_wkfl */

                              else do:

                                 /* DELETE TEMP-TABLE RECORD TO   */
                                 /* INDICATE DEFAULT sr_wkfl IS   */
                                 /* UPDATED IN MULTI-ENTRY SCREEN */

                                 find first t_sr_wkfl
                                    where sr_lineid = cline
                                    exclusive-lock no-error.

                                 if available t_sr_wkfl
                                 then
                                    delete t_sr_wkfl.

                              end. /* ELSE DO */

                              l_delete_sr_wkfl = no.

                           end. /* IF l_delete_sr_wkfl */

                        end.
                        else do:

                           if lotserial_qty <> 0
                           then do:
                              transtype     = "ISS-WO".
                              {gprun.i ""icedit.p"" "(input transtype,
                                                      input site,
                                                      input location,
                                                      input global_part,
                                                      input lotserial,
                                                      input lotref,
                                                      input lotserial_qty,
                                                      input ptum,
                                                      input """",
                                                      input """",
                                                      output undo_tran)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                              if undo_tran then undo select-part, retry.
                              /* ADDED THE FOLLOWING SECTION TO */
                              /* VALIDATE TRANSFER TRANSACTION  */
                              if wo_site <> site
                              then do:
                                 {gprun.i ""icedit4.p""
                                    "(input ""ISS-WO"",
                                                 input wo_site,
                                                 input site,
                                                 input pt_loc,
                                                 input location,
                                                 input global_part,
                                                 input lotserial,
                                                 input lotref,
                                                 input lotserial_qty,
                                                 input ptum,
                                                 """",
                                                 """",
                                                 output yn)"
                                    }
/*GUI*/ if global-beam-me-up then undo, leave.

                                 if yn then undo, retry.
                              end.
                           end.

                           find first sr_wkfl where
                              sr_userid = mfguser and
                              sr_lineid = cline
                              exclusive-lock no-error.
                           if lotserial_qty = 0
                           then do:
                              if available sr_wkfl
                              then
                                 assign
                                    total_lotserial_qty = total_lotserial_qty
                                                          - sr_qty
                                    sr_qty              = 0.

                           end.
                           else do:
                              if not available sr_wkfl
                              then do:
                                 create sr_wkfl.
                                 assign
                                    sr_userid = mfguser
                                    sr_lineid = cline.

                                 if recid(sr_wkfl) = -1 then .
                              end.

                              /* DELETE TEMP-TABLE RECORD TO */
                              /* INDICATE DEFAULT CREATED    */
                              /* RECORD IS MODIFIED          */

                              find first t_sr_wkfl
                                 where t_sr_lineid = cline
                                 exclusive-lock no-error.

                              if available t_sr_wkfl
                              then
                                 delete t_sr_wkfl.

                              assign
                                 total_lotserial_qty = lotserial_qty
                                 sr_site             = site
                                 sr_loc              = location
                                 sr_lotser           = lotserial
                                 sr_ref              = lotref
                                 sr_qty              = lotserial_qty.
                           end.
                        end.

                        pk_qty = total_lotserial_qty.
                        if lotserial_qty <> 0
                        then do:
                           {gprun.i ""reoptr1f.p""
                              "(input pk_part,
                                output yn)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                           if yn then undo, retry.
                        end.

                     end.

                     leave.
                  end.

               end. /* get part */

            end. /* do on error undo */

         end.

         repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

            yn = yes.

            /* DISPLAY WO LINES BEING SHIPPED? */
            {pxmsg.i &MSGNUM=636 &ERRORLEVEL=1
                     &CONFIRM=yn &CONFIRM-TYPE='LOGICAL'}
            if yn = yes
            then do:

               hide frame d no-pause.
               clear frame e all no-pause.
               view frame e.

               FORM /*GUI*/ 
               with frame e down width 80
                  title color normal
                  (getFrameTitle("ISSUE_DATA_REVIEW",25)) THREE-D /*GUI*/.


               for each pk_det
                  fields(pk_loc pk_part pk_qty pk_reference pk_user)
                  where pk_user = mfguser
                  no-lock:

                  l_sr_lineid = "-" + string(pk_part,"x(18)") + pk_reference.

                  for each sr_wkfl
                     fields(sr_lineid sr_loc sr_lotser sr_qty sr_ref
                            sr_site sr_userid)
                     no-lock
                     where sr_userid = mfguser
                     and   sr_lineid = l_sr_lineid
                     and   sr_qty <> 0
                     with frame e:
                     display
                        pk_part
                        sr_site
                        sr_loc
                        sr_lotser
                        sr_ref
                        sr_qty.
                     down 1 with frame e.
                  end.
               end.

            end.
            leave.
         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         do on endkey undo seta, leave seta:
            yn = yes.
            /*V8+*/
                        {mfgmsg10.i 12 1 yn } /* Is all info correct" */
            if yn = ? then
            undo seta, leave seta.   
         end.

         if yn
         then do:

            /* VALIDATE THAT NO OVERISSUE WILL OCCUR */
            {gprun.i ""reoptr1f.p""
               "(input """",
                 output rejected)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            if rejected then next setd.

            for each pk_det
               fields(pk_loc pk_part pk_qty pk_reference pk_user)
               no-lock
               where pk_user = mfguser:
/*GUI*/ if global-beam-me-up then undo, leave.


               l_sr_lineid = "-" + string(pk_part,"x(18)") + pk_reference.

               for each sr_wkfl
                  fields(sr_lineid sr_loc sr_lotser sr_qty sr_ref
                         sr_site sr_userid)
                  no-lock
                  where sr_userid = mfguser
                  and   sr_lineid = l_sr_lineid
                  and   sr_qty <> 0:

                  for first ptmstr
                     fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser pt_part pt_um)
                     where ptmstr.pt_part = pk_part
                     no-lock:
                  end. /* FOR FIRST ptmstr */

                  {gprun.i ""icedit2.p""
                     "(input ""ISS-WO"",
                                  input sr_site,
                                  input sr_loc,
                                  input pk_part,
                                  input sr_lotser,
                                  input sr_ref,
                                  input sr_qty,
                                  input ptmstr.pt_um,
                                  input """",
                                  input """",
                                  output rejected)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if rejected
                  then do:

                     /* UNABLE TO ISSUE OR RECEIVE FOR ITEM  */
                     {pxmsg.i &MSGNUM=161 &ERRORLEVEL=2
                              &MSGARG1=pk_part}
                     next setd.
                  end.

               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for each sr_wkfl */

            end. /* for each pk_det */

            hide frame d.
            hide frame e.
            leave seta.

         end. /* if yn */

      end. /* setd */

   end.

end. /* seta */

for each t_sr_wkfl
   exclusive-lock:

   delete t_sr_wkfl.

end. /* FOR EACH t_sr_wkfl */

hide frame d.
